<template>
	<div id="medicalrecord" style="width: 100%; ">

		<div style="width: 100%; height: 450px; background-color: #EAEAEA;">
			<el-form :model="insertFrm" ref="insertFrm">

				<el-row>
					<el-col :span="3">
						<el-button type="infor" @click="chufangData" style="margin-left: 50px; width: 80px;background-color: cornflowerblue;">
							<b style="color: white;">处方</b>
						</el-button>
					</el-col>
					<el-col :span="3">
						<el-button type="infor" @click="bingliData" style="margin-left: -108px; width: 80px;background-color: cornflowerblue;">
							<b style="color: white;">病历</b>
						</el-button>
					</el-col>
				</el-row>


				<!-- 第一行 -->
				<el-row>
					<el-col :span="6">
						<el-form-item label="患者姓名">
							<el-input v-model="insertFrm.name" placeholder="请输入患者姓名" style="width: 290px;"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="患者卡号">
							<el-input v-model="insertFrm.serialnumber" placeholder="请输入患者卡号" style="width: 290px;"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="患者年龄">
							<el-input v-model="insertFrm.age" placeholder="请输入患者年龄" style="width: 290px;"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="出生日期">
							<el-date-picker v-model="insertFrm.birth" value-format="yyyy-MM-dd" style="width: 290px;" placeholder="请输入出生日期">
							</el-date-picker>
						</el-form-item>
					</el-col>
				</el-row>

				<!-- 第二行 -->
				<el-row>
					<el-col :span="6">
						<el-form-item label="性别">
							<el-select v-model="insertFrm.sex" placeholder="请选择性别" style="width: 290px;">
								<el-option :id="0" :value="0">女</el-option>
								<el-option :id="1" :value="1">男</el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="手机号码">
							<el-input v-model="insertFrm.phone" placeholder="请输入手机号码" style="width: 290px;"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="证件号码">
							<el-input v-model="insertFrm.personid" placeholder="请输入证件号码" style="width: 290px;"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="患者来源">
							<el-select v-model="insertFrm.sourceId" placeholder="请选择患者来源" style="width: 290px;">
								<el-option v-for="sou in source" :label="sou.name" :value="sou.id"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>

				<!-- 第四行 -->
				<el-row>
					<el-col :span="6">
						<el-form-item label="地址">
							<el-cascader v-model="ssq" :options="ssqs" :props="ssqsprops" @change="handleChange" style="width: 290px;"></el-cascader>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="详细地址">
							<el-input v-model="insertFrm.address" placeholder="请输入详细地址" style="width: 580px;"></el-input>
						</el-form-item>
					</el-col>
				</el-row>

				<!-- 第五行 -->
				<el-row>
					<el-col :span="11">
						<el-form-item label="诊断">
							<el-select v-model="insertFrm.diagnosisId" placeholder="诊断内容" style="width: 550px;">
								<el-option v-for="dia in diagnosis" :label="dia.name" :value="dia.id"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="5">
						<el-form-item label="医嘱">
							<el-select v-model="insertFrm.adviceId" placeholder="医嘱内容" style="width: 500px;">
								<el-option v-for="adv in advice" :label="adv.name" :value="adv.id"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>

			</el-form>
		</div>

		<el-form :model="saveForm" ref="saveForm">
			<div style="width: 100%; height: 220px; background-color: aliceblue; margin-top: 15px;">

				<el-row style="margin-top: 5px;">
					<el-col :span="2">
						<b style="color: cornflowerblue; font-size: 20px;">体格信息</b>
					</el-col>
				</el-row>

				<el-row>
					<el-col :span="4">
						<el-form-item label="体温">
							<el-input v-model="saveForm.name" placeholder="请输入体温值" style="width: 150px; margin-right: 20px">℃</el-input>
							<span>℃</span>
						</el-form-item>
					</el-col>
					<el-col :span="4">
						<el-form-item label="呼吸">
							<el-input v-model="saveForm.name" placeholder="请输入呼吸次数" style="width: 150px; margin-right: 20px"></el-input>
							次/分
						</el-form-item>
					</el-col>
					<el-col :span="4">
						<el-form-item label="脉搏">
							<el-input v-model="saveForm.name" placeholder="请输入脉搏次数" style="width: 150px; margin-right: 20px"></el-input>
							次/分
						</el-form-item>
					</el-col>
					<el-col :span="4">
						<el-form-item label="血压">
							<el-input v-model="saveForm.name" placeholder="请输入血压值" style="width: :;0px; margin-right: 20px"></el-input>
							<div style="width: 50px; height: 35px; margin-top: -41px; margin-left: 212px;">
								mmHg
							</div>
						</el-form-item>
					</el-col>
				</el-row>

				<el-row>
					<el-col :span="4">
						<el-form-item label="身高">
							<el-input v-model="saveForm.name" placeholder="请输入身高" style="width: 150px; margin-right: 20px">℃</el-input>
							<span>℃</span>
						</el-form-item>
					</el-col>
					<el-col :span="4">
						<el-form-item label="体重">
							<el-input v-model="saveForm.name" placeholder="请输入体重" style="width: 150px; margin-right: 20px"></el-input>
							kg
						</el-form-item>
					</el-col>
					<el-col :span="4">
						<el-form-item label="血糖">
							<el-input v-model="saveForm.name" placeholder="请输入血糖值" style="width: 150px;margin-right: 50px;"></el-input>
							<div style="margin-left: 150px; margin-top: -41px;">mmol/l</div>
						</el-form-item>
					</el-col>
					<el-col :span="4">
						<el-form-item label="血脂">
							<el-input v-model="saveForm.name" placeholder="请输入血脂值" style="width: :;0px; margin-right: 20px"></el-input>
							<div style="width: 50px; height: 35px; margin-top: -41px; margin-left: 212px;">
								mmol/l
							</div>
						</el-form-item>
					</el-col>
				</el-row>

			</div>
			<div style="width: 100%; height: 600px; background-color: ; margin-top: 15px;">

				<el-row style="margin-top: 5px;">
					<el-col :span="12" style="margin-left: -125px;">
						<b style="color: cornflowerblue; font-size: 20px;">病例信息
							<span style="font-size: 10px; color: #D3DCE6;">(病历信息可在系统设置-基础设置中的自定义设置)</span>
						</b>
					</el-col>
				</el-row>

				<!-- 第一行 -->
				<el-row>
					<el-col :span="12">
						<el-form-item label="出生日期">
							<el-date-picker v-model="saveForm.birth" value-format="yyyy-MM-dd" style="width: 535px; margin-right: 100px;"
							 placeholder="请输入出生日期">
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="主诉">
							<el-input v-model="saveForm.name" placeholder="请输入主诉" style="width: 535px; margin-right: 100px;"></el-input>
						</el-form-item>
					</el-col>
				</el-row>

				<!-- 第二行 -->
				<el-row>
					<el-col :span="12">
						<el-form-item label="现病史">
							<el-input v-model="saveForm.name" placeholder="请输入现病史" style="width: 535px; margin-right: 100px;"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="既往史">
							<el-input v-model="saveForm.name" placeholder="请输入既往史" style="width: 535px; margin-right: 100px;"></el-input>
						</el-form-item>
					</el-col>
				</el-row>

				<!-- 第三行 -->
				<el-row>
					<el-col :span="12">
						<el-form-item label="过敏史">
							<el-input v-model="saveForm.name" placeholder="请输入过敏史" style="width: 535px; margin-right: 100px;"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="个人史">
							<el-input v-model="saveForm.name" placeholder="请输入个人史" style="width: 535px; margin-right: 100px;"></el-input>
						</el-form-item>
					</el-col>
				</el-row>

				<!-- 第四行 -->
				<el-row>
					<el-col :span="12">
						<el-form-item label="家族史">
							<el-input v-model="saveForm.name" placeholder="请输入家族史" style="width: 535px; margin-right: 100px;"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="辅助检查">
							<el-input v-model="saveForm.name" placeholder="请输入辅助检查" style="width: 535px; margin-right: 100px;"></el-input>
						</el-form-item>
					</el-col>
				</el-row>

				<!-- 第五行 -->
				<el-row>
					<el-col :span="12">
						<el-form-item label="治疗意见">
							<el-input v-model="saveForm.name" placeholder="请输入治疗意见" style="width: 535px; margin-right: 100px;"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="备注">
							<el-input v-model="saveForm.name" placeholder="请输入备注" style="width: 535px; margin-right: 100px;"></el-input>
						</el-form-item>
					</el-col>
				</el-row>

			</div>

			<div style="width: 100%; height: 70px; margin-top: -35px;">
				<el-row>
					<el-col :span="6">
						<el-button @click="saveData" type="primary" style="width: 110px; background-color: blue; margin-left: 900px;">
							<i class="el-icon-folder-checked"></i>
							保存
						</el-button>
					</el-col>
					<el-col :span="6">
						<el-button @click="over" type="primary" style="background-color: orange; margin-left: 700px;">
							<i class="el-icon-folder-checked"></i>
							结束就诊
						</el-button>
					</el-col>
				</el-row>
			</div>


		</el-form>

	</div>
</template>

<script>
	export default {
		data() {
			return {
				saveForm: {},
				diagnosis: [],
				advice: [],
				source: [],
				ssq: [],
				ssqs: [],
				ssqsprops: {
					value: 'id',
					label: 'name',
					children: 'list'
				},
				insertFrm: {}
			}
		},
		created() {
			this.diagnosisData();
			this.adviceData();
			this.areaData();
			this.sourceData();
			this.initData();
			//this.insertFrm = this.$route.query.admissionData;
		},
		methods: {
			saveData() {
				this.$router.replace({
					path: "/admission"
				})
				// this.axios.post('', this.saveForm).then(res => {
				// 	if (res.data) {

				// 		this.$message({
				// 			message: '新增患者成功',
				// 			type: 'success'
				// 		});
				// 		this.$router.replace({
				// 			path:"/admission"
				// 		})
				// 	}
				// })
			},
			over() {
				this.$confirm('确定要结束此次就诊吗?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {

					this.$router.replace({
						path: "/admission"
					})

					this.$message({
						type: 'success',
						message: '结束就诊成功!'
					});
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消就诊成功'
					});
				});

			},
			diagnosisData() {
				this.axios.get('http://localhost:9993/diagnosis/list').then(res => {
					this.diagnosis = res.data.obj;
				})
			},
			adviceData() {
				this.axios.get('http://localhost:9993/advice/list').then(res => {
					this.advice = res.data.obj;
				})
			},
			initData() {
				if (this.$route.query.admiss) {
					this.insertFrm = this.$route.query.admissionData;
					console.log(this.$route.query.admissionData);
				}

			},
			sourceData() {
				this.axios.get('http://localhost:9993/source/list').then(res => {
					this.source = res.data.obj;
				})
			},
			areaData() {
				this.axios.get('http://localhost:9993/area/findAll').then(res => {
					this.ssqs = res.data;
				})
			},
			handleChange(val) {
				this.ssq = val;
			},
			chufangData() {
				this.$router.push("/admission");
			},
			bingliData() {
				this.$router.push("/admission");
			}
		}
	}
</script>

<style>
</style>
